package com.ruoyi.shop.service.impl;

import java.util.List;
import com.ruoyi.common.utils.DateUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.shop.mapper.ShopUserFavoriteMapper;
import com.ruoyi.shop.domain.ShopUserFavorite;
import com.ruoyi.shop.service.IShopUserFavoriteService;
import com.ruoyi.common.core.text.Convert;

/**
 * 用户收藏Service业务层处理
 * 
 * @author Alan Zhang
 * @date 2021-09-14
 */
@Service
public class ShopUserFavoriteServiceImpl implements IShopUserFavoriteService 
{
    @Autowired
    private ShopUserFavoriteMapper shopUserFavoriteMapper;

    /**
     * 查询用户收藏
     * 
     * @param id 用户收藏主键
     * @return 用户收藏
     */
    @Override
    public ShopUserFavorite selectShopUserFavoriteById(Long id)
    {
        return shopUserFavoriteMapper.selectShopUserFavoriteById(id);
    }

    /**
     * 查询用户收藏列表
     * 
     * @param shopUserFavorite 用户收藏
     * @return 用户收藏
     */
    @Override
    public List<ShopUserFavorite> selectShopUserFavoriteList(ShopUserFavorite shopUserFavorite)
    {
        return shopUserFavoriteMapper.selectShopUserFavoriteList(shopUserFavorite);
    }

    /**
     * 新增用户收藏
     * 
     * @param shopUserFavorite 用户收藏
     * @return 结果
     */
    @Override
    public int insertShopUserFavorite(ShopUserFavorite shopUserFavorite)
    {
        shopUserFavorite.setCreateTime(DateUtils.getNowDate());
        return shopUserFavoriteMapper.insertShopUserFavorite(shopUserFavorite);
    }

    /**
     * 修改用户收藏
     * 
     * @param shopUserFavorite 用户收藏
     * @return 结果
     */
    @Override
    public int updateShopUserFavorite(ShopUserFavorite shopUserFavorite)
    {
        return shopUserFavoriteMapper.updateShopUserFavorite(shopUserFavorite);
    }

    /**
     * 批量删除用户收藏
     * 
     * @param ids 需要删除的用户收藏主键
     * @return 结果
     */
    @Override
    public int deleteShopUserFavoriteByIds(String ids)
    {
        return shopUserFavoriteMapper.deleteShopUserFavoriteByIds(Convert.toStrArray(ids));
    }

    /**
     * 删除用户收藏信息
     * 
     * @param id 用户收藏主键
     * @return 结果
     */
    @Override
    public int deleteShopUserFavoriteById(Long id)
    {
        return shopUserFavoriteMapper.deleteShopUserFavoriteById(id);
    }
}
